package cn.whdream.datastructure.linkedlist;

public class SingleLinkedListDemo {
	public static void main(String[] args) {
		SingleLinkedList list = new SingleLinkedList();
		list.addHeroNode(new HeroNode("宋江", "及时雨", 1));
		list.addHeroNode(new HeroNode("卢俊义", "玉麒麟", 2));
		list.addHeroNode(new HeroNode("吴用", "智多星", 3));
		list.show();
	}
	static class SingleLinkedList{
		private final HeroNode head = new HeroNode("", "", 0);
		public void addHeroNode(HeroNode node) {
			HeroNode temp = head;
			while (true) {
				if (temp.next == null) {
					break;
				}
				temp = temp.next;
			}
			temp.next = node;
			
		}
		
		public void show() {
			HeroNode temp = head;
			while (true) {
				if (temp.next == null) {
					break;
				}
				System.out.println(temp.next);
				temp = temp.next;
			}
		}
	}
	static class HeroNode{
		String name;
		String nickName;
		int no;
		HeroNode next;
		public HeroNode(String name, String nickName, int no) {
			super();
			this.name = name;
			this.nickName = nickName;
			this.no = no;
		}
		@Override
		public String toString() {
			return "HeroNode [name=" + name + ", nickName=" + nickName + ", no=" + no + "]";
		}
		
	}
}
